2020-2021 Sunseeker Telemetry and Lighting System
dac12_a_ex3_positiveRampInt.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 //******************************************************************************
63 //******************************************************************************
64 
65 #include "driverlib.h"
66 
67 static uint16_t dataToConvert = 0;
68 
69 void main (void)
70 {
71  //Stop Watchdog Timer
72  WDT_A_hold(WDT_A_BASE);
73 
74  /*
75  * // Initialize DAC12_A_0,
76  * // Choose P7.6 as output
77  * // Use AVcc as Vref+
78  * // Multiply Vout by 1
79  * // Use medium settling speed/current
80  * // Use Timer_B OUT2 as data-latch trigger
81  */
82  DAC12_A_initParam param = {0};
83  param.submoduleSelect = DAC12_A_SUBMODULE_0;
84  param.outputSelect = DAC12_A_OUTPUT_1;
85  param.positiveReferenceVoltage = DAC12_A_VREF_AVCC;
86  param.outputVoltageMultiplier = DAC12_A_VREFx1;
87  param.amplifierSetting = DAC12_A_AMP_MEDIN_MEDOUT;
88  param.conversionTriggerSelect = DAC12_A_TRIGGER_TB;
89  DAC12_A_init(DAC12_A_BASE, &param);
90 
91  //Enable the DAC12_A_0 interrupt
92  DAC12_A_enableInterrupt(DAC12_A_BASE,
93  DAC12_A_SUBMODULE_0);
94 
95  //Calibrate output buffer for DAC12_A_0
96  DAC12_A_calibrateOutput(DAC12_A_BASE,
97  DAC12_A_SUBMODULE_0);
98 
99  //Enable conversions for DAC12_A_0
100  DAC12_A_enableConversions(DAC12_A_BASE,
101  DAC12_A_SUBMODULE_0);
102 
104  DAC12_A_setData(DAC12_A_BASE,
105  DAC12_A_SUBMODULE_0,
106  dataToConvert
107  );
108 
109  //Start Timer B0
110  Timer_B_initUpModeParam initUpModeParam = {0};
111  initUpModeParam.clockSource = TIMER_B_CLOCKSOURCE_SMCLK;
112  initUpModeParam.clockSourceDivider = TIMER_B_CLOCKSOURCE_DIVIDER_1;
113  initUpModeParam.timerPeriod = 0x33;
114  initUpModeParam.timerInterruptEnable_TBIE = TIMER_B_TBIE_INTERRUPT_DISABLE;
115  initUpModeParam.captureCompareInterruptEnable_CCR0_CCIE =
116  TIMER_B_CCIE_CCR0_INTERRUPT_DISABLE;
117  initUpModeParam.timerClear = TIMER_B_DO_CLEAR;
118  initUpModeParam.startTimer = true;
119  Timer_B_initUpMode(TIMER_B0_BASE, &initUpModeParam);
120 
121 
122  Timer_B_initCompareModeParam initCompParam = {0};
123  initCompParam.compareRegister = TIMER_B_CAPTURECOMPARE_REGISTER_2;
124  initCompParam.compareInterruptEnable = TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE;
125  initCompParam.compareOutputMode = TIMER_B_OUTPUTMODE_TOGGLE;
126  initCompParam.compareValue = 0x32;
127  Timer_B_initCompareMode(TIMER_B0_BASE, &initCompParam);
128 
129  //Enter LPM0
130  __bis_SR_register(CPUOFF + GIE);
131 }
132 
133 //******************************************************************************
134 //
135 //This is the DAC12_A_VECTOR interrupt vector service routine.
136 //
137 //******************************************************************************
138 #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
139 #pragma vector=DAC12_VECTOR
140 __interrupt
141 #elif defined(__GNUC__)
142 __attribute__((interrupt(DAC12_VECTOR)))
143 #endif
144 void DAC12_A_ISR (void)
145 {
146  //Clear interrupt flag to stop asserts
147  DAC12_A_clearInterrupt(DAC12_A_BASE,
148  DAC12_A_SUBMODULE_0);
149 
150  //Increment ramp
151  dataToConvert++;
152 
153  //Set the variable dataToConvert into data buffer for DAC12_A_0
154  DAC12_A_setData(DAC12_A_BASE,
155  DAC12_A_SUBMODULE_0,
156  dataToConvert
157  );
158  __no_operation();
159 }
MPU_initThreeSegmentsParam param
Timer_A_initUpModeParam initUpModeParam
void main(void)
void DAC12_A_ISR(void)
__no_operation()